 
/**
 * 度分秒转经纬度
 * @param dfm  86°37'33"  ---》87.2013
 * @returns {number}
 */
function convertGPSToXY(dfm) {
	const arr1 = dfm.split('°');
	const d = arr1[0];
	const arr2 = arr1[1].split("'")
	let f = arr2[0] || 0;
	const m = arr2[1].replace('"', '') || 0;
	f = parseFloat(f) + parseFloat(m / 60);
	var du = parseFloat(f / 60) + parseFloat(d);
	return du;
}

/**
 * 经纬度转度分秒  
 * @param point  [87.2013,87.2013]   或者 87.2013,87.2013
 * @returns {*} [86°37'33",88°58'24"]   或者 86°37'33",88°58'24"
 */
function convertXYToGPS (point) {
	let xy;
	if (point instanceof Array) {
		xy = point;
	} else {
		point = point + "";
		xy = point.split(',');
	}

	let dPoint = [];
	let dPointStr = "";
	for (let i = 0; i < xy.length; i++) {
		const mElement = xy[i] + "";
		const arr1 = mElement.split(".");
		const d = arr1[0];
		let tp = "0." + arr1[1]
		tp = String(tp * 60); //这里进行了强制类型转换
		const arr2 = tp.split(".");
		const f = arr2[0];
		tp = "0." + arr2[1];
		tp = tp * 60;
		const m = tp.toFixed(2);
		const dfm = d + "°" + f + "′" + m + "″";
		dPointStr += "," + dfm;
		dPoint.push(dfm);
	}

	dPointStr = dPointStr.replace(',', '');

	return point instanceof Array ? dPoint : dPointStr;
}

  
export {			//关键
	convertGPSToXY,
	convertXYToGPS,
}